
public class ArrayDemo2 {

	public static void main(String[] args) {
		// create and assign values to an array at the same time.
		
		
		String[] names = {"Henry", "Mira","Raji", "Ravi","Satya","Siva"};
		
		
		
		//this is how using for loop for the same but always easy to use for each loop to read all the values.
		
		for(int i=0; i<names.length; i++){
			
			System.out.println("Name = " + names[i]);
		}
		
		//for each loop
		for(String name : names){
			
			System.out.println("Name = " + name);
		}

	
	
	// if we run the following then we got output as error. at line no.28 we got array index out of bounds exception.
			System.out.println("seventh name ="+ names[6]); 

}
}
